# -*- coding: utf-8 -*-

import os
import h5py
import numpy as np
import cv2


def get_images_path(folder):
    images_folder = os.path.join(folder, "images")
    images_path = [os.path.join(images_folder, name)
                   for name in os.listdir(images_folder) if "jpg" in name]
    ground_truths_path = [path.replace("images", "ground_truth").replace("jpg", "h5")
                          for path in images_path]
    return images_path, ground_truths_path


def process_image(image_path, ground_truth_path):
    image = cv2.imread(image_path)
    image = image.astype(dtype=np.float32, copy=False)
    image = np.divide(image, 255)
    h5_file = h5py.File(ground_truth_path, "r")
    ground_truth = np.array(h5_file["data"])
    h5_file.close()
    return image, ground_truth
